﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Formality
{
    public class SequenceEqualityComparer<T> : IEqualityComparer<IEnumerable<T>>
    {
        public bool Equals(IEnumerable<T> x, IEnumerable<T> y)
        {
            return x == null || y == null ? x == y : x.SequenceEqual(y);
        }

        public int GetHashCode(IEnumerable<T> Seq)
        {
            var Hash = 0;
            foreach (var e in Seq)
                Hash ^= e.GetHashCode();
            return Hash;
        }
    }
}
